package com.evil.kingdom.utils;

import com.evil.kingdom.pojo.entity.base.Fight;

import java.util.Arrays;

/**
 * 战斗工具类
 *
 * @author liyang
 * @date 2024-05-17 17:08
 */
public class FightUtil {

    /**
     * 合计攻击力
     *
     * @param fights fights
     * @return Double
     */
    public Double attack(Fight... fights) {
        if (null == fights) {
            return 0d;
        }
        return Arrays.stream(fights).mapToDouble(Fight::getAttack).sum();
    }

    /**
     * 合计防御力
     *
     * @param fights fights
     * @return Double
     */
    public Double defense(Fight... fights) {
        if (null == fights) {
            return 0d;
        }
        return Arrays.stream(fights).mapToDouble(Fight::getDefense).sum();
    }

    /**
     * 合计智力
     *
     * @param fights fights
     * @return Double
     */
    public Double brain(Fight... fights) {
        if (null == fights) {
            return 0d;
        }
        return Arrays.stream(fights).mapToDouble(Fight::getBrain).sum();
    }

    /**
     * 合计攻击速度
     *
     * @param fights fights
     * @return Double
     */
    public Double attackSpeed(Fight... fights) {
        if (null == fights) {
            return 0d;
        }
        return Arrays.stream(fights).mapToDouble(Fight::getAttackSpeed).sum();
    }

    /**
     * 合计速度
     *
     * @param fights fights
     * @return Double
     */
    public Double speed(Fight... fights) {
        if (null == fights) {
            return 0d;
        }
        return Arrays.stream(fights).mapToDouble(Fight::getSpeed).sum();
    }
}
